package jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class JDBCDemo10 {
    public static void main(String[] args) {
        try (Connection connection = DBUtil.getConnection();){
            String sql = "UPDATE userinfo SET password = ?,nickname = ?,age = ? WHERE id = ?";
            PreparedStatement preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setString(1,"0909090909");
            preparedStatement.setString(2,"泡泡人");
            preparedStatement.setInt(3,90);
            preparedStatement.setInt(4,21);
            int number = preparedStatement.executeUpdate();
            System.out.println(number > 0 ? "修改成功" : "修改失败");
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}